<!doctype html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>SB共享单车</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="assets/css/admin.css">
    <link rel="stylesheet" href="assets/css/app.css">
</head>

<body data-type="generalComponents">

<header class="am-topbar am-topbar-inverse admin-header">
    <div class="am-topbar-brand">
        <a href="javascript:;" class="tpl-logo">
            <img src="assets/img/logo.png" alt="">
        </a>
    </div>
    <div class="am-icon-list tpl-header-nav-hover-ico am-fl am-margin-right">

    </div>

    <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only"
            data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span
            class="am-icon-bars"></span></button>

    <div class="am-collapse am-topbar-collapse" id="topbar-collapse">

        <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list tpl-header-list">

            <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
                <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
                    <span class="tpl-header-list-user-nick" id="userName">none</span><span
                        class="tpl-header-list-user-ico"> <img src="assets/img/user01.png"></span>
                </a>
            </li>
            <li><a id = "quit" class="tpl-header-list-link"><span
                    class="am-icon-sign-out tpl-header-list-ico-out-size"></span></a></li>
        </ul>
    </div>
</header>

<div class="tpl-page-container tpl-page-header-fixed">

    <div class="tpl-left-nav tpl-left-nav-hover">
        <div class="tpl-left-nav-title" style="font-size: 16px;margin-bottom: 15px;margin-top: -10px;">
            ShareBike管理系统
        </div>
        <div class="tpl-left-nav-list">
            <ul class="tpl-left-nav-menu">
                <li class="tpl-left-nav-item">
                    <a href="index" class="nav-link">
                        <i class="am-icon-home"></i>
                        <span>首页</span>
                    </a>
                </li>
                <li class="tpl-left-nav-item">
                    <a href="javascript:;" class="nav-link tpl-left-nav-link-list">
                        <i class="am-icon-table"></i>
                        <span>维修管理</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu">
                        <li>
                            <a href="waitRepairBike">
                                <i class="am-icon-angle-right"></i>
                                <span>查看待维修车辆</span>
                            </a>
                        </li>
                        <li>
                            <a href="RepairFinshRecord">
                                <i class="am-icon-angle-right"></i>
                                <span>查看已完成维修记录</span>
                            </a>
                        </li>
                        <li>
                            <a href="RepairUnFinshRecord">
                                <i class="am-icon-angle-right"></i>
                                <span>查看未完成维修记录</span>
                            </a>
                        </li>
                        <li>
                            <a href="beginRepairBike">
                                <i class="am-icon-angle-right"></i>
                                <span>开始维修</span>
                            </a>
                        </li>
                        <li>
                            <a href="finshRepairBike">
                                <i class="am-icon-angle-right"></i>
                                <span>完成维修</span>
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="tpl-left-nav-item">
                    <a href="javascript:;" class="nav-link tpl-left-nav-link-list active">
                        <i class="am-icon-wpforms"></i>
                        <span>车辆管理</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu">
                        <li>
                            <a href="AdminFindAllBike">
                                <i class="am-icon-angle-right"></i>
                                <span>查看车辆</span>
                            </a>
                        </li>
                    </ul>
                    <ul class="tpl-left-nav-sub-menu">
                        <li>
                            <a href="AdminaAddBike" class="active">
                                <i class="am-icon-angle-right"></i>
                                <span>添加车辆</span>
                            </a>
                        </li>
                    </ul>
                    <ul class="tpl-left-nav-sub-menu">
                        <li>
                            <a href="AdminaAddBikeType">
                                <i class="am-icon-angle-right"></i>
                                <span>添加车辆种类</span>
                            </a>
                        </li>
                    </ul>
                    <ul class="tpl-left-nav-sub-menu">
                        <li>
                            <a href="AdminFindBikeByDetail">
                                <i class="am-icon-angle-right"></i>
                                <span>车辆统计</span>
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="tpl-left-nav-item">
                    <a href="javascript:;" class="nav-link tpl-left-nav-link-list">
                        <i class="am-icon-child"></i>
                        <span>人员管理</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu">
                        <li>
                            <a href="AdminFindAllUser">
                                <i class="am-icon-angle-right"></i>
                                <span>查看用户列表</span>
                            </a>
                        </li>
                        <li>
                            <a href="AdminFindAllUser">
                                <i class="am-icon-angle-right"></i>
                                <span>查询用户信息</span>
                            </a>
                        </li>
                        <li>
                            <a href="AdminFindAllUser">
                                <i class="am-icon-angle-right"></i>
                                <span>添加维修员</span>
                            </a>
                        </li>
                        <li>
                            <a href="AdminFindAllUser">
                                <i class="am-icon-angle-right"></i>
                                <span>修改用户信息</span>
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <div class="tpl-content-wrapper">
        <div class="tpl-content-page-title">
           车辆管理
        </div>
        <ol class="am-breadcrumb">
            <li><a href="index" class="am-icon-home">首页</a></li>
            <li><a href="#">车辆管理</a></li>
            <li class="am-active">添加车辆</li>
        </ol>
        <div class="tpl-portlet-components">
            <div class="portlet-title">
                <div class="caption font-green bold">
                    <span class="am-icon-code">添加车辆</span>
                </div>
            </div>
            <div class="tpl-block">
                <div class="am-g">
                    <form class="am-form am-u-sm-offset-3 am-u-sm-6 am-u-end">
                        <fieldset>
                            <legend>请输入车辆类型和数量</legend>
                            <div class="am-form-group am-form-select">
                                <label >车辆类型</label>
                                <select class=" am-input-sm" id="opt">
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                </select>
                            </div>
                            <div class="am-form-group">
                                <label >新增数量</label>
                                <input type="number" onfocus="this.blur();" min="1" max="100" class="am-form-field am-radius" id="bikeNumber" placeholder="输入新增数量">
                            </div>
                            <button type="button" class="am-btn am-btn-default am-u-sm-2 am-u-sm-offset-5" id="summit">添加</button>
                        </fieldset>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/app.js"></script>
<script src="js/my.js" th:inline="javascript"></script>
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    var user = /*[[${session.user}]]*/ null;
    if (user == null) {
        alert("请先登录");
        window.location.href = "login"
    } else if(user.grade != 2){
        alert("您没有权限访问该网页");
        window.location.href = "index"
    }else {
        $('#userName').text(user.userName);
    }
    $(function () {
        $.ajax({
            type: "post",
            url: "/admin/getBikeKind",
            contentType: "application/json;charset=utf-8",
            success: function (result) {
                if(result.code == 101){
                    $("#opt").empty();
                    $.each(result.list, function (index, data) {
                        var kind;
                        if (data.kind == 0){
                            kind = "自行车";
                        }else{
                            kind = "电动车";
                        }
                        $("#opt").append(
                        '<option value="'+data.typeId+'">'+data.supplier+','+kind+'</option>'
                        );
                    });
                }
            }
        })
    });
    $('#summit').click(function () {
        var mydata = {}
        mydata.typeId = $('#opt').val()
        mydata.number = $('#bikeNumber').val()
        $.ajax({
            type:"post",
            url: "/admin/addBike",
            data:JSON.stringify(mydata),
            contentType: "application/json;charset=utf-8",
            success:function(result){
                alert(result)
                window.location.hrefhref ="AdminFindAllBike"
            }
        })
    })
    /*]]>*/
</script>
</body>

</html>